/* 
合并多个reducer, 产生一个根/总reducer
*/
import {combineReducers} from 'redux'
import counter from './counter'
import search from './search'
import { CounterState, SearchState } from './types'

// 合并 counter和search 两个reducer
// 给每个reducer都指定了对应的标识名称
const rootReducer = combineReducers({
  counter,
  search
})

export default rootReducer

/* 
根reducer管理的是所有reducer的状态的集合对象

{
  counter: {count: 0}
  search: {
    firstView: true,
    loading: false,
    errMsg: '',
    users: []
  }
}
*/

// 向外暴露根state的结构
export interface RootState {
  counter: CounterState,
  search: SearchState
}